package com.cskaoyan.mall.util;


/**
 * @author: jyf2000jyf
 */
public class UpdateOrAddAdminUtils {
    public static boolean judgeEmail(String email) {
        int split = email.lastIndexOf("@qq.com");
        String qqNum = email.substring(0, split);
        String substring1 = email.substring(split);
        if (qqNum.length() < 5 || qqNum.length() > 12) {
            return false;
        } else {
            char[] chars = qqNum.toCharArray();
            for (char aChar : chars) {
                if (aChar < '0' || aChar > '9') {
                    return false;
                }
            }
        }
        if (!substring1.equals("@qq.com")) {
            return false;
        }
        return true;
    }

    public static boolean judgeNickname(String nickname) {
        if (nickname.length() < 4 || nickname.length() > 15) {
            return false;
        }
        return true;
    }

    public static boolean judgePassword(String password) {
        if (password.length() < 8 || password.length() > 16) {
            return false;
        }
        char[] chars = password.toCharArray();
        int countUpper = 0;
        int countLower = 0;
        int countNum = 0;
        int countSymbol = 0;
        for (char aChar : chars) {
            if (aChar >= '0' && aChar <= '9') {
                countNum++;
            } else if (aChar >= 'a' && aChar <= 'z') {
                countLower++;
            } else if (aChar >= 'A' && aChar <= 'Z') {
                countUpper++;
            } else if (aChar >= 31 && aChar != 127) {
                countSymbol++;
            }
        }
        if (countUpper == 0 || countLower == 0 || countNum == 0 || countSymbol == 0) {
            return false;
        }
        return true;
    }
}
